﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace BallData
{
    public class MatchData
    {
        // 联赛联盟 英超 意甲 德甲 U19等
        public Hashtable LeagueList = new Hashtable();
        // 所有联赛列表
        private Hashtable MatchList = new Hashtable();

        public Hashtable Matchs
        {
            get { return MatchList; }
            set { MatchList = value; }
        }
        // 赌博公司列表
        public Hashtable CompanyList = new Hashtable();
        public Hashtable CTypeNum = new Hashtable();
        // 更新时间
        public DateTime TimeStamp;
        // 改过时间
        public DateTime ChgTime;

        public Int32 LeagueNum;
        public Int32 MatchNum;
        public Int32 CompanyNum;
        public Boolean hasChg;
        public DateTime lastTime;
        public DateTime lastChgTime;
        public DateTime chgTime;
        public Hashtable CaiPiaoMatchList = new Hashtable();

        public MatchData()
        {

        }
        public MatchItem getMatchItem(String mId)
        {
            return this.Matchs[mId] as MatchItem;
        }
        public LeagueItem getLeagueItem(String lId)
        {

            return this.LeagueList[lId] as LeagueItem;
        }
        public MatchItem getMatchItemByName(String cnName)
        {
            foreach (MatchItem mi in this.Matchs.Values)
            {
                if (mi.t1CnName == cnName)
                {
                    return mi;
                }
            }
            return null;
        }
        public MatchItem getMatchItemByName(List<String> ListName)
        {
            foreach (MatchItem mi in this.Matchs.Values)
            {
                if (ListName.Contains(mi.t1CnName) 
                    || ListName.Contains(mi.t2CnName)
                    || ListName.Contains(mi.t1EnName)
                    || ListName.Contains(mi.t2EnName))
                {
                    return mi;
                }
                else
                {
                    foreach (String name in ListName)
                    {
                        if ((mi.t1CnName.Length >= 2 && mi.t1CnName.StartsWith(name.Substring(0, 2)))
                            && (mi.t2CnName.Length >= 2 && mi.t2CnName.StartsWith(name.Substring(0, 2))))
                        {
                                return mi;
                        }
                        else if ((mi.t1EnName.Length >= 2 && mi.t1EnName.StartsWith(name.Substring(0, 2)))
                            && (mi.t2EnName.Length >= 2 && mi.t2EnName.StartsWith(name.Substring(0, 2))))
                        {
                            return mi;
                        }
                        else if ((mi.t1TrName.Length >= 2 && mi.t1TrName.StartsWith(name.Substring(0, 2)))
                            && (mi.t2TrName.Length >= 2 && mi.t2TrName.StartsWith(name.Substring(0, 2))))
                        {
                            return mi;
                        }
                    }
                }

            }
            return null;
        }
        //public Hashtable companyoddsdata = new Hashtable();
        //public List<OddsChg> listoddschg = new List<OddsChg>();
        // 每个公司的比赛赔率数据
        public Hashtable companymatchsodds = Hashtable.Synchronized(new Hashtable());
        //public G_Odds g_odds = new G_Odds();

        //竞猜场次比赛信息
        public Hashtable Issueinfotable = new Hashtable();

    }
}
